Use global defined index of datum WGS84 and OSGB36.
authoroliskoli <oliskoli>
Sat, 14 Apr 2007 15:25:20 +0000 (15:25 +0000)
committeroliskoli <oliskoli>
Sat, 14 Apr 2007 15:25:20 +0000 (15:25 +0000)
compegps.c
defs.h
dmtlog.c
garmin_txt.c

index 3156c55bd740bb82793f93666eb93fd6cdb1a17c..b65b6912bc00480564dbc7fc9e725f16cf198d44 100644 (file)
@@ -106,16 +106,11 @@ static
 void fix_datum(double *lat, double *lon)
 {
        double amt;
-       static int wgs84;
-
-       if (wgs84 == 0) {
-               wgs84 = GPS_Lookup_Datum_Index("WGS 84");
-       }
 
        /*
         * Avoid FP jitter in the common case.
         */
-       if (input_datum != wgs84) {
+       if (input_datum != DATUM_WGS84) {
                GPS_Math_Known_Datum_To_WGS84_M(*lat, *lon, 0.0, lat, lon, 
                        &amt, input_datum);
        }
@@ -341,7 +336,7 @@ static void
 compegps_rd_init(const char *fname)
 {
        fin = gbfopen(fname, "rb", MYNAME);
-       input_datum = GPS_Lookup_Datum_Index("WGS 84");
+       input_datum = DATUM_WGS84;
 }
 
 static void
diff --git a/defs.h b/defs.h
index 43d30bd95abd06414b17527333bd811e8defa876..c0c68e56d12cd9e8adc09a250a0b3d031ea67ed6 100644 (file)
--- a/defs.h
+++ b/defs.h
@@ -861,6 +861,8 @@ typedef enum {
 
 #define GRID_INDEX_MIN grid_lat_lon_ddd
 #define GRID_INDEX_MAX grid_utm
+
+#define DATUM_OSGB36   86
 #define DATUM_WGS84    118
 
 int parse_coordinates(const char *str, int datum, const grid_type grid,
index 785ab0050811b8568937a8515f819d099bb68907..9a88c50aa08879f435d6ca15937e3f964aed3a6e 100644 (file)
--- a/dmtlog.c
+++ b/dmtlog.c
@@ -38,7 +38,7 @@ static char *xmlbin;
 static waypoint *xmlwpt;
 static route_head *xmltrk;
 static char *xmlgrid;
-static int xmldatum, datum_WGS84, datum_OSGB36;
+static int xmldatum;
 static double xmlEasting, xmlNorthing;
 static double xmlLatitude, xmlLongitude;
 static double xmlAltitude;
@@ -105,7 +105,7 @@ static xg_tag_mapping tlog3b_xgcb_map[] = {
 static void
 convert_datum(waypoint *wpt, int datum)
 {
-       if (datum != datum_WGS84) {
+       if (datum != DATUM_WGS84) {
                double lat = wpt->latitude;
                double lon = wpt->longitude;
                double alt = wpt->altitude;
@@ -122,7 +122,7 @@ finalize_pt(waypoint *wpt)
        if (strcmp(xmlgrid, "BNG") == 0) {
                GPS_Math_NGENToAiry1830LatLon(xmlEasting, xmlNorthing, 
                &wpt->latitude, &wpt->longitude);
-               xmldatum = datum_OSGB36;
+               xmldatum = DATUM_OSGB36;
        }
        else {
                wpt->latitude = xmlLatitude;
@@ -219,7 +219,7 @@ static void
 tlog3b_xgcb_wptst(const char *args, const char **unused)
 {
        xmlwpt = waypt_new();
-       xmldatum = datum_WGS84;
+       xmldatum = DATUM_WGS84;
 }
 
 
@@ -227,7 +227,7 @@ static void
 tlog3b_xgcb_tptst(const char *args, const char **unused)
 {
        xmlwpt = waypt_new();
-       xmldatum = datum_WGS84;
+       xmldatum = DATUM_WGS84;
 }
 
 
@@ -551,9 +551,6 @@ dmtlog_rd_init(const char *fname)
 {
        fin = gbfopen_le(fname, "rb", MYNAME);
        
-       datum_OSGB36 = GPS_Lookup_Datum_Index("OSGB36");
-       datum_WGS84 = GPS_Lookup_Datum_Index("WGS84");
-       
        xmlbin = NULL;
        xmltrk = NULL;
        xmlwpt = NULL;
index bb8444f0226e87b38cc10484dab92c934f87fdb2..3638510d3af2538618a51e190eb8f8c6e1b7b8fe 100644 (file)
@@ -765,7 +765,7 @@ garmin_txt_wr_init(const char *fname)
        
        switch(grid_index) {
        case grid_bng: /* force datum to "Ord Srvy Grt Britn" */
-               datum_index = gt_lookup_datum_index("OSGB36", MYNAME);
+               datum_index = DATUM_OSGB36;
                break;
        default:
                datum_index = gt_lookup_datum_index(datum_str, MYNAME);